import redis

#定义地址和端口

host = '127.0.0.1'
port = 6379

#建立redis连接
r = redis.Redis(host=host,port=port)

  # 生命周期的使用
r.set('123','123')
r.expire('123',10)
print(r.get('123'))

# #声明一个值
# r.set('test','321')

# #取值
# code = r.get('test')


# #转码
# code = code.decode('utf-8')

# print(code)

# r.sadd("testset","爆款")
# r.sadd("testset","爆款")
# r.sadd("testset","修身")
#
# #查询
#
# myset = r.smembers("testset")
# print(myset)
# myset = list(myset)
# mytag = str(myset[0],"utf-8")
# print(mytag)